<?php

require_once './include/common.inc.php';

$page_title = 'jans2en furniture - Products - Product Details';
$menu_id = 5;

getMyParam('categoryid');
getMyParam('pid');


// *** page code start ***

$sql = "SELECT `id`, `name`, `pic` FROM `photo` WHERE `photo_category_id`=$categoryid AND `type` = 1";
$query = $db->query($sql);
$sql_all_num = $db->num_rows($query);

$ppp = 1;
getMyParam('page');
$page = empty($page) || !ispage($page) ? 1 : $page;
$start_limit = ($page - 1) * $ppp;
if($start_limit > $sql_all_num) {
    $start_limit = 0;
    $page = 1;
}

$back_page = $page>1 ? $page-1 : 1;
$next_page = $page<$sql_all_num ? $page+1 : $sql_all_num;
$back_page_url = 'product_photo_details.php?categoryid=' . $categoryid . '&page=' . $back_page;
$next_page_url = 'product_photo_details.php?categoryid=' . $categoryid . '&page=' . $next_page;
// *** page code end ***

$photo_ary = array();
$sql = "SELECT `id`, `name`, `pic`, `photo_category_id`, `description` FROM `photo` WHERE `photo_category_id`=$categoryid  AND `type` = 1 ORDER BY `seq` ASC, `id` DESC LIMIT $start_limit, $ppp";
$product_info_ary = $db->get_one($sql);
//echo "<pre>";print_r($product_info_ary);
if (empty($product_info_ary)) {
    echo "<script>window.close();</script>";
    exit;
}


if (trim($product_info_ary['pic']) == "" || !file_exists("./zh/attachments/" . $product_info_ary['pic'])) {
	$product_info_ary['pic'] = 'no_398x398.gif';
}

$size_ary = getimagesize("./zh/attachments/" . $product_info_ary['pic']);
if ($size_ary[0]>$size_ary[1]) {
	$width = 398;
	$height = @($size_ary[1]/$size_ary[0]*398);
} else {
	$height = 398;
	$width = @($size_ary[0]/$size_ary[1]*398);
}

$sql = "SELECT `id`, `name` FROM `category` WHERE `fid` = 0 AND `id` = '$categoryid' ORDER BY `seq` ASC, `id` DESC";
$tmp_ary = $db->get_one($sql);
$guide_name = $tmp_ary['name'];

//$guide_name = trim($c2_name) != '' ? $c1_name . "&gt;" . $c2_name : $c1_name;

require_once PrintEot('product_photo_details');

?>